# use normal make for this Makefile
#
# Makefile for building user programs to run on top of Nachos
#
# Several things to be aware of:
#
#    Nachos assumes that the location of the program startup routine (the
# 	location the kernel jumps to when the program initially starts up)
#       is at location 0.  This means: start.o must be the first .o passed 
# 	to ld, in order for the routine "Start" to be loaded at location 0
#

# If you are running on SunOS 5.x machines, uncomment the next line
GCCDIR = /auto/home-scf-22/csci402/testgnu/decstation-ultrix/bin/
LDFLAGS = -T newscript -N
ASFLAGS = -mips1
CPPFLAGS = $(INCDIR)

# if you aren't cross-compiling:
# GCCDIR =
# LDFLAGS = -N -T 0
# ASFLAGS =
# CPPFLAGS = -P $(INCDIR)


CC = $(GCCDIR)gcc
AS = $(GCCDIR)as
LD = $(GCCDIR)ld
CPP = $(GCCDIR)cpp

INCDIR =-I../userprog -I../threads
CFLAGS = -G 0 -c $(INCDIR)

all: halt matmult sort testfiles testP2 testP3 testP4 testP3d testP4Menu testP4SuiteA1 testP4SuiteA2 testP4SuiteB1 testP4SuiteB2 testP4SuiteB3 testP4SuiteC1 testP4SuiteD1 testP4SuiteD2 testP4SuiteD3 theater theater2 testP3a testExec testExec2 testSignal testWait testAcquire testAcquire2 testRelease testRelease2 testBroadcast testCreate testCreate2 HeadCustomer RegularCustomer main1 main2 main3 main4 main5 main6 TicketClerk ConcessionClerk TicketTaker Technician Manager

start.o: start.s ../userprog/syscall.h
	$(CPP) $(CPPFLAGS) start.s > strt.s
	$(AS) $(ASFLAGS) -o start.o strt.s
	rm strt.s

halt.o: halt.c
	$(CC) $(CFLAGS) -c halt.c
halt: halt.o start.o
	$(LD) $(LDFLAGS) start.o halt.o -o halt.coff
	../bin/coff2noff halt.coff halt

sort.o: sort.c
	$(CC) $(CFLAGS) -c sort.c
sort: sort.o start.o
	$(LD) $(LDFLAGS) start.o sort.o -o sort.coff
	../bin/coff2noff sort.coff sort

matmult.o: matmult.c
	$(CC) $(CFLAGS) -c matmult.c
matmult: matmult.o start.o
	$(LD) $(LDFLAGS) start.o matmult.o -o matmult.coff
	../bin/coff2noff matmult.coff matmult
	
testP2.o: testP2.c
	$(CC) $(CFLAGS) -c testP2.c
testP2: testP2.o start.o
	$(LD) $(LDFLAGS) start.o testP2.o -o testP2.coff
	../bin/coff2noff testP2.coff testP2
	
testP3.o: testP3.c
	$(CC) $(CFLAGS) -c testP3.c
testP3: testP3.o start.o
	$(LD) $(LDFLAGS) start.o testP3.o -o testP3.coff
	../bin/coff2noff testP3.coff testP3	
	
testP3a.o: testP3a.c
	$(CC) $(CFLAGS) -c testP3a.c
testP3a: testP3a.o start.o
	$(LD) $(LDFLAGS) start.o testP3a.o -o testP3a.coff
	../bin/coff2noff testP3a.coff testP3a
	
testP3d.o: testP3d.c
	$(CC) $(CFLAGS) -c testP3d.c
testP3d: testP3d.o start.o
	$(LD) $(LDFLAGS) start.o testP3d.o -o testP3d.coff
	../bin/coff2noff testP3d.coff testP3d

testExec.o: testExec.c
	$(CC) $(CFLAGS) -c testExec.c
testExec: testExec.o start.o
	$(LD) $(LDFLAGS) start.o testExec.o -o testExec.coff
	../bin/coff2noff testExec.coff testExec

testExec2.o: testExec2.c
	$(CC) $(CFLAGS) -c testExec2.c
testExec2: testExec2.o start.o
	$(LD) $(LDFLAGS) start.o testExec2.o -o testExec2.coff
	../bin/coff2noff testExec2.coff testExec2
	
testWait.o: testWait.c
	$(CC) $(CFLAGS) -c testWait.c
testWait: testWait.o start.o
	$(LD) $(LDFLAGS) start.o testWait.o -o testWait.coff
	../bin/coff2noff testWait.coff testWait
	
testSignal.o: testSignal.c
	$(CC) $(CFLAGS) -c testSignal.c
testSignal: testSignal.o start.o
	$(LD) $(LDFLAGS) start.o testSignal.o -o testSignal.coff
	../bin/coff2noff testSignal.coff testSignal

testBroadcast.o: testBroadcast.c
	$(CC) $(CFLAGS) -c testBroadcast.c
testBroadcast: testBroadcast.o start.o
	$(LD) $(LDFLAGS) start.o testBroadcast.o -o testBroadcast.coff
	../bin/coff2noff testBroadcast.coff testBroadcast
	
testAcquire.o: testAcquire.c
	$(CC) $(CFLAGS) -c testAcquire.c
testAcquire: testAcquire.o start.o
	$(LD) $(LDFLAGS) start.o testAcquire.o -o testAcquire.coff
	../bin/coff2noff testAcquire.coff testAcquire

testAcquire2.o: testAcquire2.c
	$(CC) $(CFLAGS) -c testAcquire2.c
testAcquire2: testAcquire2.o start.o
	$(LD) $(LDFLAGS) start.o testAcquire2.o -o testAcquire2.coff
	../bin/coff2noff testAcquire2.coff testAcquire2
	
testRelease.o: testRelease.c
	$(CC) $(CFLAGS) -c testRelease.c
testRelease: testRelease.o start.o
	$(LD) $(LDFLAGS) start.o testRelease.o -o testRelease.coff
	../bin/coff2noff testRelease.coff testRelease

testRelease2.o: testRelease2.c
	$(CC) $(CFLAGS) -c testRelease2.c
testRelease2: testRelease2.o start.o
	$(LD) $(LDFLAGS) start.o testRelease2.o -o testRelease2.coff
	../bin/coff2noff testRelease2.coff testRelease2
	
testCreate.o: testCreate.c
	$(CC) $(CFLAGS) -c testCreate.c
testCreate: testCreate.o start.o
	$(LD) $(LDFLAGS) start.o testCreate.o -o testCreate.coff
	../bin/coff2noff testCreate.coff testCreate

testCreate2.o: testCreate2.c
	$(CC) $(CFLAGS) -c testCreate2.c
testCreate2: testCreate2.o start.o
	$(LD) $(LDFLAGS) start.o testCreate2.o -o testCreate2.coff
	../bin/coff2noff testCreate2.coff testCreate2

testP4Menu.o: testP4Menu.c
	$(CC) $(CFLAGS) -c testP4Menu.c
testP4Menu: testP4Menu.o start.o
	$(LD) $(LDFLAGS) start.o testP4Menu.o -o testP4Menu.coff
	../bin/coff2noff testP4Menu.coff testP4Menu	

testP4SuiteA1.o: testP4SuiteA1.c
	$(CC) $(CFLAGS) -c testP4SuiteA1.c
testP4SuiteA1: testP4SuiteA1.o start.o
	$(LD) $(LDFLAGS) start.o testP4SuiteA1.o -o testP4SuiteA1.coff
	../bin/coff2noff testP4SuiteA1.coff testP4SuiteA1	
	
testP4SuiteA2.o: testP4SuiteA2.c
	$(CC) $(CFLAGS) -c testP4SuiteA2.c
testP4SuiteA2: testP4SuiteA2.o start.o
	$(LD) $(LDFLAGS) start.o testP4SuiteA2.o -o testP4SuiteA2.coff
	../bin/coff2noff testP4SuiteA2.coff testP4SuiteA2
	
testP4SuiteB1.o: testP4SuiteB1.c
	$(CC) $(CFLAGS) -c testP4SuiteB1.c
testP4SuiteB1: testP4SuiteB1.o start.o
	$(LD) $(LDFLAGS) start.o testP4SuiteB1.o -o testP4SuiteB1.coff
	../bin/coff2noff testP4SuiteB1.coff testP4SuiteB1
	
testP4SuiteB2.o: testP4SuiteB2.c
	$(CC) $(CFLAGS) -c testP4SuiteB2.c
testP4SuiteB2: testP4SuiteB2.o start.o
	$(LD) $(LDFLAGS) start.o testP4SuiteB2.o -o testP4SuiteB2.coff
	../bin/coff2noff testP4SuiteB2.coff testP4SuiteB2
	
testP4SuiteB3.o: testP4SuiteB3.c
	$(CC) $(CFLAGS) -c testP4SuiteB3.c
testP4SuiteB3: testP4SuiteB3.o start.o
	$(LD) $(LDFLAGS) start.o testP4SuiteB3.o -o testP4SuiteB3.coff
	../bin/coff2noff testP4SuiteB3.coff testP4SuiteB3
	
testP4SuiteC1.o: testP4SuiteC1.c
	$(CC) $(CFLAGS) -c testP4SuiteC1.c
testP4SuiteC1: testP4SuiteC1.o start.o
	$(LD) $(LDFLAGS) start.o testP4SuiteC1.o -o testP4SuiteC1.coff
	../bin/coff2noff testP4SuiteC1.coff testP4SuiteC1
	
testP4SuiteD1.o: testP4SuiteD1.c
	$(CC) $(CFLAGS) -c testP4SuiteD1.c
testP4SuiteD1: testP4SuiteD1.o start.o
	$(LD) $(LDFLAGS) start.o testP4SuiteD1.o -o testP4SuiteD1.coff
	../bin/coff2noff testP4SuiteD1.coff testP4SuiteD1
	
testP4SuiteD2.o: testP4SuiteD2.c
	$(CC) $(CFLAGS) -c testP4SuiteD2.c
testP4SuiteD2: testP4SuiteD2.o start.o
	$(LD) $(LDFLAGS) start.o testP4SuiteD2.o -o testP4SuiteD2.coff
	../bin/coff2noff testP4SuiteD2.coff testP4SuiteD2
	
testP4SuiteD3.o: testP4SuiteD3.c
	$(CC) $(CFLAGS) -c testP4SuiteD3.c
testP4SuiteD3: testP4SuiteD3.o start.o
	$(LD) $(LDFLAGS) start.o testP4SuiteD3.o -o testP4SuiteD3.coff
	../bin/coff2noff testP4SuiteD3.coff testP4SuiteD3
	
testP4.o: testP4.c
	$(CC) $(CFLAGS) -c testP4.c
testP4: testP4.o start.o
	$(LD) $(LDFLAGS) start.o testP4.o -o testP4.coff
	../bin/coff2noff testP4.coff testP4
	
theater.o: theater.c
	$(CC) $(CFLAGS) -c theater.c
theater: theater.o start.o
	$(LD) $(LDFLAGS) start.o theater.o -o theater.coff
	../bin/coff2noff theater.coff theater
	
theater2.o: theater2.c
	$(CC) $(CFLAGS) -c theater2.c
theater2: theater2.o start.o
	$(LD) $(LDFLAGS) start.o theater2.o -o theater2.coff
	../bin/coff2noff theater2.coff theater2
	
testfiles.o: testfiles.c
	$(CC) $(CFLAGS) -c testfiles.c
testfiles: testfiles.o start.o
	$(LD) $(LDFLAGS) start.o testfiles.o -o testfiles.coff
	../bin/coff2noff testfiles.coff testfiles
	

HeadCustomer.o: HeadCustomer.c
	$(CC) $(CFLAGS) -c HeadCustomer.c
HeadCustomer: HeadCustomer.o start.o
	$(LD) $(LDFLAGS) start.o HeadCustomer.o -o HeadCustomer.coff
	../bin/coff2noff HeadCustomer.coff HeadCustomer	

RegularCustomer.o: RegularCustomer.c
	$(CC) $(CFLAGS) -c RegularCustomer.c
RegularCustomer: RegularCustomer.o start.o
	$(LD) $(LDFLAGS) start.o RegularCustomer.o -o RegularCustomer.coff
	../bin/coff2noff RegularCustomer.coff RegularCustomer	

TicketClerk.o: TicketClerk.c
	$(CC) $(CFLAGS) -c TicketClerk.c
TicketClerk: TicketClerk.o start.o
	$(LD) $(LDFLAGS) start.o TicketClerk.o -o TicketClerk.coff
	../bin/coff2noff TicketClerk.coff TicketClerk	
	
ConcessionClerk.o: ConcessionClerk.c
	$(CC) $(CFLAGS) -c ConcessionClerk.c
ConcessionClerk: ConcessionClerk.o start.o
	$(LD) $(LDFLAGS) start.o ConcessionClerk.o -o ConcessionClerk.coff
	../bin/coff2noff ConcessionClerk.coff ConcessionClerk	
	
TicketTaker.o: TicketTaker.c
	$(CC) $(CFLAGS) -c TicketTaker.c
TicketTaker: TicketTaker.o start.o
	$(LD) $(LDFLAGS) start.o TicketTaker.o -o TicketTaker.coff
	../bin/coff2noff TicketTaker.coff TicketTaker	
	
Technician.o: Technician.c
	$(CC) $(CFLAGS) -c Technician.c
Technician: Technician.o start.o
	$(LD) $(LDFLAGS) start.o Technician.o -o Technician.coff
	../bin/coff2noff Technician.coff Technician	
	
Manager.o: Manager.c
	$(CC) $(CFLAGS) -c Manager.c
Manager: Manager.o start.o
	$(LD) $(LDFLAGS) start.o Manager.o -o Manager.coff
	../bin/coff2noff Manager.coff Manager	
	
main1.o: main1.c
	$(CC) $(CFLAGS) -c main1.c
main1: main1.o start.o
	$(LD) $(LDFLAGS) start.o main1.o -o main1.coff
	../bin/coff2noff main1.coff main1

main2.o: main2.c
	$(CC) $(CFLAGS) -c main2.c
main2: main2.o start.o
	$(LD) $(LDFLAGS) start.o main2.o -o main2.coff
	../bin/coff2noff main2.coff main2

main3.o: main3.c
	$(CC) $(CFLAGS) -c main3.c
main3: main3.o start.o
	$(LD) $(LDFLAGS) start.o main3.o -o main3.coff
	../bin/coff2noff main3.coff main3

main4.o: main4.c
	$(CC) $(CFLAGS) -c main4.c
main4: main4.o start.o
	$(LD) $(LDFLAGS) start.o main4.o -o main4.coff
	../bin/coff2noff main4.coff main4

main5.o: main5.c
	$(CC) $(CFLAGS) -c main5.c
main5: main5.o start.o
	$(LD) $(LDFLAGS) start.o main5.o -o main5.coff
	../bin/coff2noff main5.coff main5

main6.o: main6.c
	$(CC) $(CFLAGS) -c main6.c
main6: main6.o start.o
	$(LD) $(LDFLAGS) start.o main6.o -o main6.coff
	../bin/coff2noff main6.coff main6
	
clean:
	rm -f *.o *.coff
